package cn.wolfcode.mycat.test;

import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;

/**
 * @author Create by dell on 2021/3/16.
 */
public class RestClientConfiguration {

    public static RestHighLevelClient getClient() {

//        String one_node = FileTransferProperties.getString("slave_one_node", GetProperties.getValue("slave_one_node"));
//        String two_node = FileTransferProperties.getString("slave_two_node", GetProperties.getValue("slave_two_node"));
//        String three_node = FileTransferProperties.getString("slave_three_node", GetProperties.getValue("slave_three_node"));
	    RestClientBuilder restClientBuilder = RestClient.builder(new HttpHost("192.168.1.164", 9200, "http"));
		/*restClientBuilder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
			@Override
			public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpAsyncClientBuilder) {
				CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
				credentialsProvider.setCredentials(AuthScope.ANY,new UsernamePasswordCredentials(userName,password));
				return httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
			}
		});*/
	    RestHighLevelClient client = new RestHighLevelClient(restClientBuilder);
        return client;
    }
    
}
